Ext.namespace("org.microsite.project");

Project.prototype.getType = function() {return 'Project';};

org.microsite.util.ViewRegistry.add(new org.microsite.util.ViewHelper({
    type : Project,
    service : ProjectRemote,
    editor : org.microsite.project.ProjectEditor,
    template : new Ext.XTemplate('<table border="0" cellspacing="5">',
            '<tr><td><b>Name</b></td><td>{name}</td></tr>',
            '<tr><td><b>Description</b></td><td>{description}</td></tr>',
            '<tr><td><b>Filesets</b></td><td>',
                '<tpl for="fileSet">{name}<br/></tpl>',
            '</td></tr>',
             
            '</table>'),
    fields : [{name:'id'},{name:'name'},{name:'description'},{name:'fileSet'}],
    
    fillData : function(data, cb, scopeObject) {
        var tmp = Ext.apply({}, data);
        if (tmp.fileSet) {
            FileSetRemote.sublistInProject(tmp.id, {
                callback : function(list) {
                    tmp.fileSet = list;
                    if (cb != null) cb.call(scopeObject, tmp);
                },
                scope : this
            })
        } else if (cb != null) cb.call(scopeObject, tmp);
    }
}));
